package com.lzxuni.modules.cropinformation.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lzxuni.common.utils.StringUtils;
import com.lzxuni.modules.common.entity.PageParameter;
import com.lzxuni.modules.common.entity.Tree;
import com.lzxuni.modules.cropinformation.entity.TblCropInformation;
import com.lzxuni.modules.cropinformation.mapper.TblCropInformationMapper;
import com.lzxuni.modules.cropinformation.service.TblCropInformationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 作物信息 服务实现类
 * </p>
 *
 * @author rdf
 * @since 2020-11-24
 */
@Service
public class TblCropInformationServiceImpl extends ServiceImpl<TblCropInformationMapper, TblCropInformation> implements TblCropInformationService {

    @Override
    public PageInfo<TblCropInformation> queryPage(PageParameter pageParameter, TblCropInformation cropInformation) {
        if (StringUtils.isNotEmpty(pageParameter.getSidx())) {
            PageHelper.startPage(pageParameter.getPage(), pageParameter.getRows()).setOrderBy(
                    pageParameter.getSidx() + " " + pageParameter.getSord());
        } else {
            PageHelper.startPage(pageParameter.getPage(), pageParameter.getRows());
        }
        List<TblCropInformation> cropInformationList = baseMapper.queryList(cropInformation);
        PageInfo<TblCropInformation> pageInfo = new PageInfo<>(cropInformationList);
        return pageInfo;
    }

    @Override
    public List<Tree> getTree() {
        List<Tree> list = baseMapper.queryListtree();
        return list;
    }

    @Override
    public List<Tree> getTreekh(String cropName) {
        List<Tree> modellist = baseMapper.queryListmodeltree(cropName);
        return modellist;
    }

    @Override
    public int queryfarmerUpdateByCropId(TblCropInformation tblCropInformation) {
//        tblCropInformation.setCropId(keyValue);
        return baseMapper.queryfarmerUpdateByCropId(tblCropInformation);
    }
    @Override
    public List<TblCropInformation> queryCountList(){
        return baseMapper.queryCountList();
    }
}
